package com.pr.makfilm.domain;

import org.hibernate.validator.constraints.Length;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

/**
 * Created with IntelliJ IDEA.
 * User: Balbina
 * Date: 01.12.13
 * Time: 23:27
 * To change this template use File | Settings | File Templates.
 */
@Entity
@Table(name = "district")
public class District extends IdentifiableEntity
{
   public static final String FIELD_NAME = "name";

   public static final String FIELD_USER = "user";

   public static final String FIELD_DESCRIPTION = "description";

   public static final int MAX_LENGTH_NAME = 25;

   @Id
   @GeneratedValue
   @Column
   private Long id;

   @Column(nullable = false, length = MAX_LENGTH_NAME)
   @NotNull
   @Length(max = MAX_LENGTH_NAME)
   private String name;

   @ManyToOne(cascade = {CascadeType.MERGE, CascadeType.PERSIST}, fetch = FetchType.LAZY)
   @JoinColumn(nullable = false)
   @NotNull
   private User user;

   @Column
   private String description;

   public Long getId()
   {
      return id;
   }

   public void setId(Long id)
   {
      this.id = id;
   }

   public String getName()
   {
      return name;
   }

   public void setName(String name)
   {
      this.name = name;
   }

   public User getUser()
   {
      return user;
   }

   public void setUser(User user)
   {
      this.user = user;
   }

   public String getDescription()
   {
      return description;
   }

   public void setDescription(String description)
   {
      this.description = description;
   }
}
